package com.a918.service.impl;

import com.a918.dao.MemBwgMapper;
import com.a918.dao.MemOthMapper;
import com.a918.dao.MemPerMapper;
import com.a918.entity.MemBwg;
import com.a918.entity.MemBwgWithBLOBs;
import com.a918.entity.MemOth;
import com.a918.entity.MemPerWithBLOBs;
import com.a918.service.AnalyseService;
import com.a918.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AnalyseServiceImp implements AnalyseService {

    private MemBwgMapper memBwgMapper;
    private MemPerMapper memPerMapper;
    private MemOthMapper memOthMapper;

    @Autowired
    public AnalyseServiceImp(MemBwgMapper memBwgMapper, MemPerMapper memPerMapper, MemOthMapper memOthMapper) {
        this.memBwgMapper = memBwgMapper;
        this.memPerMapper = memPerMapper;
        this.memOthMapper = memOthMapper;
    }


    @Override
    public Map<String,Object> bwgIndustryType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> industrytype = memBwgMapper.tjIndustryType();
        List<String> industryTypeName = new ArrayList<>();
        List<Integer> industryTypeNum = new ArrayList<>();
        for(Map<String, Object> i: industrytype){
            industryTypeName.add((String)i.get("industryType"));
            industryTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("industryTypeName",industryTypeName);
        res.put("industryTypeNum",industryTypeNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgMuseumType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆类型统计
        List<Map<String, Object>> museumtype = memBwgMapper.tjMuseumType();
        List<String> museumTypeName = new ArrayList<>();
        List<Integer> museumTypeNum = new ArrayList<>();
        for(Map<String, Object> i: museumtype){
            museumTypeName.add((String)i.get("museumType"));
            museumTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("museumTypeName",museumTypeName);
        res.put("museumTypeNum",museumTypeNum);
        return res;
    }

    @Override
    public Map<String,Object> bwgMainVistorType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆主要观众类型统计
        List<Map<String, Object>> mainvisitortype = memBwgMapper.tjMainVistorType();
        List<String> mainvistorTypeName = new ArrayList<>();
        List<Integer> mainvistorTypeNum = new ArrayList<>();
        for(Map<String, Object> i: mainvisitortype){
            mainvistorTypeName.add((String)i.get("mainVistorType"));
            mainvistorTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("mainvistorTypeName", mainvistorTypeName);
        res.put("mainvistorTypeNum", mainvistorTypeNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgFarenType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆主要观众类型统计
        List<Map<String, Object>> farentype = memBwgMapper.tjFarenType();
        List<String> farenTypeName = new ArrayList<>();
        List<Integer> farenTypeNum = new ArrayList<>();
        for(Map<String, Object> i: farentype){
            if((Integer)i.get("isSelffaren")==1) {
                farenTypeName.add("是");
            }else{
                farenTypeName.add("否");
            }
            farenTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("farenTypeName", farenTypeName);
        res.put("farenTypeNum", farenTypeNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgProvince() {
        Map<String, Object> res = new HashMap<>();
        //博物馆主要观众类型统计
        List<Map<String, Object>> province = memBwgMapper.tjProvince();
        List<String> provinceTypeName = new ArrayList<>();
        List<Integer> provinceTypeNum = new ArrayList<>();
        for(Map<String, Object> i: province){
            provinceTypeName.add((String)i.get("province"));
            provinceTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("provinceTypeName", provinceTypeName);
        res.put("provinceTypeNum", provinceTypeNum);

        return res;
    }


    @Override
    public Map<String,Object> bwgBuildingArea() {
        Map<String, Object> res = new HashMap<>();
        //博物馆馆舍面积统计
        List<Map<String, Object>> buildingArea = memBwgMapper.tjBuildingArea();
        List<Float> buildingAreaNum = new ArrayList<>();
        for(Map<String, Object> i: buildingArea){
            buildingAreaNum.add(Float.valueOf(i.get("num").toString()));
        }
        res.put("buildingAreaNum", buildingAreaNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgShowArea() {
        Map<String, Object> res = new HashMap<>();
        //博物馆馆舍面积统计
        List<Map<String, Object>> showArea = memBwgMapper.tjShowArea();
        List<Float> showAreaNum = new ArrayList<>();
        for(Map<String, Object> i: showArea){
            showAreaNum.add(Float.valueOf(i.get("num").toString()));
        }
        res.put("showAreaNum", showAreaNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgCangpinNum() {
        Map<String, Object> res = new HashMap<>();
        //博物馆藏品数量统计
        List<Map<String, Object>> cangpin = memBwgMapper.tjCangpinNum();
        List<Integer> cangpinNum = new ArrayList<>();
        for(Map<String, Object> i: cangpin){
            cangpinNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("cangpinNum", cangpinNum);

        return res;
    }

    @Override
    public Map<String,Object> bwgEmployeeNum() {
        Map<String, Object> res = new HashMap<>();
        //博物馆藏品数量统计
        List<Map<String, Object>> employee = memBwgMapper.tjEmployeeNum();
        List<Integer> employeeNum = new ArrayList<>();
        for(Map<String, Object> i: employee){
            employeeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("employeeNum", employeeNum);

        return res;
    }


    @Override
    public Map<String,Object> perIndustryType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> industrytype = memPerMapper.tjIndustryType();
        List<String> industryTypeName = new ArrayList<>();
        List<Integer> industryTypeNum = new ArrayList<>();
        for(Map<String, Object> i: industrytype){
            industryTypeName.add((String)i.get("industryType"));
            industryTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("industryTypeName",industryTypeName);
        res.put("industryTypeNum",industryTypeNum);

        return res;
    }


    @Override
    public Map<String,Object> perUnitType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> industrytype = memPerMapper.tjUnitType();
        List<String> unitTypeName = new ArrayList<>();
        List<Integer> unitTypeNum = new ArrayList<>();
        for(Map<String, Object> i: industrytype){
            unitTypeName.add((String)i.get("unitType"));
            unitTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("unitTypeName",unitTypeName);
        res.put("unitTypeNum",unitTypeNum);

        return res;
    }

    @Override
    public Map<String,Object> perXueLi() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> xueli = memPerMapper.tjXueLi();
        List<String> xueliName = new ArrayList<>();
        List<Integer> xueliNum = new ArrayList<>();
        for(Map<String, Object> i: xueli){
            xueliName.add((String)i.get("xueli"));
            xueliNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("xueliName",xueliName);
        res.put("xueliNum",xueliNum);

        return res;
    }

    @Override
    public Map<String,Object> perPoliticalStatus() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> xueli = memPerMapper.tjPoliticalStatus();
        List<String> politicalStatusName = new ArrayList<>();
        List<Integer> politicalStatusNum = new ArrayList<>();
        for(Map<String, Object> i: xueli){
            politicalStatusName.add((String)i.get("politicalStatus"));
            politicalStatusNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("politicalStatusName",politicalStatusName);
        res.put("politicalStatusNum",politicalStatusNum);

        return res;
    }

    @Override
    public Map<String,Object> othIndustryType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> industrytype = memOthMapper.tjIndustryType();
        List<String> industryTypeName = new ArrayList<>();
        List<Integer> industryTypeNum = new ArrayList<>();
        for(Map<String, Object> i: industrytype){
            industryTypeName.add((String)i.get("industryType"));
            industryTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("industryTypeName",industryTypeName);
        res.put("industryTypeNum",industryTypeNum);

        return res;
    }

    @Override
    public Map<String,Object> othUnitType() {
        Map<String, Object> res = new HashMap<>();
        //博物馆工业类型
        List<Map<String, Object>> industrytype = memOthMapper.tjUnitType();
        List<String> unitTypeName = new ArrayList<>();
        List<Integer> unitTypeNum = new ArrayList<>();
        for(Map<String, Object> i: industrytype){
            unitTypeName.add((String)i.get("unitType"));
            unitTypeNum.add(Integer.valueOf(i.get("num").toString()));
        }
        res.put("unitTypeName",unitTypeName);
        res.put("unitTypeNum",unitTypeNum);

        return res;
    }


    @Override
    public Map<String,Object> othEmployeeNum() {
        Map<String, Object> res = new HashMap<>();
        //博物馆藏品数量统计
        List<Map<String, Object>> employee = memOthMapper.tjEmployeeNum();
        List<Integer> employeeNum = new ArrayList<>();
        for(Map<String, Object> i: employee){
            employeeNum.add((Integer)i.get("num"));
        }
        res.put("employeeNum", employeeNum);

        return res;
    }

}
